<?php
require_once MODEL_DIR.'/NewsModel.php';
$oNewsInstance = new NewsModel();

if(isset($_GET['option'])){
	if(isset($_POST['submit'], $_POST['idNews'])){
		switch($_GET['option']){
			case 'check':
				NewsModel::editNews($_POST);
				header('Location: index.php?page=adminIndex&mod=news&action=edit');
			break;
			case 'edit':
				$aiassNewsList = $oNewsInstance->getNews('WHERE idNews = '.$_POST['idNews']);
				$asmNews = $aiassNewsList[0];
				require_once VIEW_DIR.'/formNewsEdit.php';
			break;
			default:
				header('Location: index.php?page=adminIndex&mod=news&action=edit');
			break;
		}
	}
}else{
	$aiassNewsList = $oNewsInstance->getNews();
	require_once VIEW_DIR.'/formNewsSelectEdit.php';
}
